package sum.SumProvinceMarriages;

import org.apache.hadoop.io.WritableComparable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

public class SumProMarriagesBean implements WritableComparable<SumProMarriagesBean> {
    private String year;
    private String province;

    public SumProMarriagesBean(){

    }

    public SumProMarriagesBean(String year,String province){
        this.year = year;
        this.province = province;
    }

    public void set(String year,String province){
        this.year = year;
        this.province = province;
    }

    public String getYear() {
        return year;
    }

    public void setYear(String year) {
        this.year = year;
    }

    public String getProvince() {
        return province;
    }

    public void setProvince(String province) {
        this.province = province;
    }

    @Override
    public String toString() {
        return year + "\t" + province;
    }

    @Override
    public void write(DataOutput dataOutput) throws IOException {
        dataOutput.writeUTF(year);
        dataOutput.writeUTF(province);
    }

    @Override
    public void readFields(DataInput dataInput) throws IOException {
        this.year = dataInput.readUTF();
        this.province = dataInput.readUTF();
    }

    @Override
    public int compareTo(SumProMarriagesBean o) {
        int res = this.year.compareTo(o.year);
        if(res!=0){
            return res;
        }else {
            return this.province.compareTo(o.province);
        }
    }

}
